package com.cet.designapplication.pay.facade;

import com.cet.designapplication.pay.strategy.context.PayContext;
import com.cet.designapplication.pay.strategy.factory.AbstractPayContextFactory;
import com.cet.designapplication.pay.strategy.factory.PayContextFactory;
import com.cet.designapplication.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author NSOC
 */
@Component
public class PayFacade {

    @Autowired
    private AbstractPayContextFactory<PayContext> payContextFactory;

    public String pay(Order order, Integer payType) {
        PayContext payContext = payContextFactory.getContext(payType);
        return payContext.execute(order);
    }
}
